home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-13 | 8.6 KB | 425 lines | [TEXT/MPS ] |
- CASE OBJ
- STRING ASIS
-
- include 'SysEqu.a'
- include 'QuickEqu.a'
- include 'ToolEqu.a'
- include 'Traps.a'
- include 'GestaltEqu.a'
- include 'Icons.a'
- include 'FSEqu.a'
- include 'Sound.a'
-
- kHFSDispatchTrapWord equ $60
- kMountVolTrapWord equ $F
- kUnmountVolTrapWord equ $E
-
- kVolumeMountSelector equ 65
- kGetCatInfoSelector equ 9
-
- kLoadedIcon equ -4064
- kNotLoadedIcon equ $81
- kIconDisposerIconID equ 128
-
- kOnMask equ $0001
- kCDMask equ $0002
- kNetVolMask equ $0004
- kFloppyMask equ $0008
- kLocalMask equ $0010
-
- gestaltIconDisposer equ 'byeb'
-
- Macro
- PatchHeader &oldTrapAddress
- String AsIs
- dc.l 'byeb'
- String Pascal
- &oldTrapAddress: jmp $12345678
- EndM
-
- GlobalVariables Record 0
- globalSize equ *
- EndR
-
- InstallIconDisposer Proc Export
- Import HFSDispatchPatch, oldHFSDispatch
- Import MountVolPatch, oldMountVol
- Import UnmountVolPatch, oldUnmountVol
- Import ShowINIT
- Import IconDisposerGestalt
-
- tst.w $17A
- bpl.s @noCmdKey
- move.w #kNotLoadedIcon, d1
- bra.w @showIcon
-
- @noCmdKey
- move.l a0,-(sp) ; Save handle to init
- move.l #gestaltIconDisposer, d0
- _Gestalt
- cmpi.w #gestaltDupSelectorErr,d0 ; See if globals are already installed
- bne.s @continueLoad ; Go ahead and install ourselves
- addq #4,sp ; Pop the handle
- move.w #kNotLoadedIcon, d1
- bra.w @showIcon
-
- @continueLoad
- _DetachResource
-
- move.l TheZone,-(sp) ; Save the current zone
- move.l SysZone,TheZone ; Make the system zone the current zone
-
- move.w #51, d0
- _NewHandle ,Sys,Clear
- move.l a0, a2
-
- move.l (a2), a3
-
- lea IconDisposerGestalt,a1
- move.l a2,2(a1) ; Save handle to globals in our gestalt routine
- subq #2,sp
- move.l #gestaltIconDisposer,d0 ; IconDisposer selector type
- move.l a1,a0 ; A1 still has pointer to Gestalt routine
- _NewGestalt
- addq #2,sp
-
- move.l (sp)+, TheZone ; Restore the current zone
-
- @getPreferences
- subq #4, sp
- move.l #'glob', -(sp)
- move.w #1, -(sp)
- _Get1Resource
- move.l (sp)+, d0
- beq.s @noPrefs
- move.l d0, a0
- move.l (a0), a0
- move.b (a0), d6
- ext.w d6
- move.b d6, d5
- bra.s @shouldPatchTraps
-
- @noPrefs
- moveq #0, d6
- moveq #0, d5
-
- @shouldPatchTraps
- move.b d6, (a3)
- andi.w #kOnMask, d5
- bne.s @patchTraps
- move.w #kNotLoadedIcon, d1 ; We don't want to be on.
- bra.w @showIcon
-
- @patchTraps
- move.w #kHFSDispatchTrapWord,d0
- _GetTrapAddress ,NewOS
- lea oldHFSDispatch, a1
- move.l a0,2(a1)
- lea HFSDispatchPatch, a0
- move.w #kHFSDispatchTrapWord,d0
- _SetTrapAddress ,NewOS ; Apply our patch to HFSDispatch
-
- move.w #kMountVolTrapWord,d0
- _GetTrapAddress ,NewOS
- lea oldMountVol, a1
- move.l a0,2(a1)
- lea MountVolPatch, a0
- move.w #kMountVolTrapWord,d0
- _SetTrapAddress ,NewOS ; Apply our patch to MountVol
-
- move.w #kUnmountVolTrapWord,d0
- _GetTrapAddress ,NewOS
- lea oldUnmountVol, a1
- move.l a0,2(a1)
- lea UnmountVolPatch, a0
- move.w #kUnmountVolTrapWord,d0
- _SetTrapAddress ,NewOS ; Apply our patch to UnmountVol
-
- @noGlobals
- move.l $2+VCBQHdr, d1
-
- move.l d1, a1
- beq.s @successfulLoad
- move.w VCB.vcbVRefNum(A1), d1
- neg.w d1
- ext.l d1
- add.l d1, a3
- move.w VCB.vcbFSID(A1), d1
- move.w d1, d1
- beq.s @check1Floppy ; This is an HFS volume.
- ; Check if its a floppy.
-
- move.b d6, d5
- andi.b #kNetVolMask, d5
- beq.s @successfulLoad
-
- @hideIconsOnVol
- moveq #1, d0
- move.b d0, (a3)
- bra.s @successfulLoad
-
- @check1Floppy
- move.w VCB.vcbDrvNum(a1), d2
- cmpi.w #1, d2 ; Is this drive #1?
- beq.s @checkDo
- cmpi.w #2, d2 ; Is this drive #2?
- bne.s @checkCD
- @checkDo
- move.b d6, d5
- andi.b #kFloppyMask, d5
- beq.s @successfulLoad
- bra.s @hideIconsOnVol
-
- ; Now check to see if it is a CD.
-
- @checkCD
- move.w VCB.vcbAtrb(a1), d2
- btst #7, d2
- beq.s @checkLocalVol
- move.b d6, d5
- andi.b #kCDMask, d5
- beq.s @successfulLoad
- bra.s @hideIconsOnVol
-
- ; Check if it is a local harddrive.
-
- @checkLocalVol
- move.b d6, d5
- andi.b #kLocalMask, d5
- beq.s @successfulLoad
- bra.s @hideIconsOnVol
-
- @successfulLoad
- move.w #kLoadedIcon, d1
-
- @showIcon
- move.w d1, -(sp)
- move.w #-1, -(sp)
- jsr ShowINIT ; Show our init
- rts
-
- EndProc
-
- ;_________________________________________________________________________________________
- ; MountVol patch checks if a volume should have it's custom icons displayed.
-
- MountVolPatch Proc Export
- Export oldMountVol
- Import CheckVolume
-
- bra.s PatchStart
- PatchHeader oldMountVol
-
- PatchStart
- bsr.s oldMountVol
- cmpi.w #volOnLinErr, d0
- beq.s @handleAnyway ; On a chooser mount, they use an AFP
- ; mount command. Since I don't want to
- ; patch the .XPP driver, I will just
- ; handle it from here, since the AFP
- ; mount eventually calls MountVol
-
- move.l d0, d0
- bne.s @noRestoreExit ; If there was an error, leave
-
- @handleAnyway
- bsr CheckVolume
-
- @noRestoreExit
- rts
- EndProc
-
- ;_________________________________________________________________________________________
- ; UnmountVol patch clears any information stored about a volume.
-
- UnmountVolPatch Proc Export
- Export oldUnmountVol
-
- bra.s PatchStart
- PatchHeader oldUnmountVol
-
- PatchStart
- movem.l d0/a0/a3-a4, -(sp)
-
- move.l a0, a4
-
- move.l #gestaltIconDisposer, d0
- _Gestalt ; Get our globals
- move.l (a0),a3
-
- move.b (a3), d0
- andi.b #kOnMask, d0
- beq.s @done
-
- move.w VolumeParam.ioVRefNum(a4), d0
- neg.w d0
- ext.l d0
- add.l d0, a3
-
- moveq #0, d0
- move.b d0, (a3)
-
- @done
- movem.l (sp)+, d0/a0/a3-a4
-
- bra.s oldUnmountVol
-
- EndProc
-
- ;_________________________________________________________________________________________
- ; HFSDispatch patch to turn custom icon bit off and check for volumemount calls.
-
- HFSDispatchPatch Proc Export
- Export oldHFSDispatch
- Import CheckVolume
-
- bra.s PatchStart
- PatchHeader oldHFSDispatch
-
- PatchStart
- cmpi.w #kGetCatInfoSelector, d0
- bne.s @checkVolumeMount
- bsr.s oldHFSDispatch
-
- movem.l d0-d1/a0/a3-a4, -(sp)
-
- move.l a0, a4
-
- move.l #gestaltIconDisposer, d0
- _Gestalt ; Get our globals
- move.l (a0),a3
-
- move.b (a3), d0
- andi.b #kOnMask, d0
- beq.s @done
-
- move.w CInfoPBRec.hFileInfo.ioVRefNum(a4), d0
- neg.w d0
- ext.l d0
- add.l d0, a3
-
- move.b (a3), d0
- beq.s @done
-
- move.w #$FBFF, d1
- and.w d1, CInfoPBRec.hFileInfo.ioFlFndrInfo.fdFlags(a4)
-
- @done
- movem.l (sp)+, d0-d1/a0/a3-a4
- rts
-
- @checkVolumeMount
- cmpi.w #kVolumeMountSelector, d0
- bne.s oldHFSDispatch
- _Debugger
- bsr.s oldHFSDispatch
-
- bsr CheckVolume
-
- rts
- EndProc
-
- ;_________________________________________________________________________________________
- ; CheckVolume routine
-
- CheckVolume Proc Export
-
- movem.l d0-d5/a2-a4, -(sp)
-
- move.l a0, a4
-
- move.l #gestaltIconDisposer, d0
- _Gestalt ; Get our globals
- move.l (a0),a3
-
- move.b (a3), d4
- move.b d4, d5
- andi.b #kOnMask, d5
- beq.s @done
-
- tst.b $17B
- bne.s @done ; If you want to see the icons,
- ; on a volume, hold down control
-
- move.w VolumeParam.ioVRefNum(a4), d0
- move.w d0, d2
- neg.w d0
- ext.l d0
- add.l d0, a3
-
- move.l $2+VCBQHdr, d1
- @loop
- move.l d1, a2
- beq.s @done
- move.w VCB.vcbVRefNum(A2), d1
- cmp.w d2, d1
- bne.s @nextItem
- move.w VCB.vcbFSID(A2), d1
- move.w d1, d1
- beq.s @check1Floppy ; This is an HFS volume.
- ; Check if its a floppy.
-
- move.b d4, d5
- andi.b #kNetVolMask, d5
- beq.s @done
-
- @hideIconsOnVol
- moveq #1, d0
- move.b d0, (a3)
- bra.s @done
-
- @check1Floppy
- move.w VCB.vcbDrvNum(a2), d2
- cmpi.w #1, d2 ; Is this drive #1?
- beq.s @checkDo
- cmpi.w #2, d2 ; Is this drive #2?
- bne.s @checkCD
- @checkDo
- move.b d4, d5
- andi.b #kFloppyMask, d5
- beq.s @done
- bra.s @hideIconsOnVol
-
- ; Now check to see if it is a CD.
-
- @checkCD
- move.w VCB.vcbAtrb(a2), d2
- btst #7, d2
- beq.s @checkLocalVol
- move.b d4, d5
- andi.b #kCDMask, d5
- beq.s @done
- bra.s @hideIconsOnVol
-
- @checkLocalVol
- move.b d4, d5
- andi.b #kLocalMask, d5
- beq.s @done
- bra.s @hideIconsOnVol
-
- @nextItem
- move.l VCB.qLink(A2), d1
- bra.s @loop
-
- @done
- movem.l (sp)+, d0-d5/a2-a4
- rts
- EndProc
-
- ;_________________________________________________________________________________________
- ; Gestalt routine
-
- IconDisposerGestalt Proc Export
- bra.s GestaltStart
- globalHandle
- ds.l 1 ; Handle to IconDisposer globals stored here
- GestaltStart
- move.l (sp)+,a0 ; Get return address
- move.l (sp)+,a1 ; Get address to stash global handle
- move.l globalHandle,(a1)
- addq #4,sp ; Pop selector
- clr.w (sp) ; Return noErr
- jmp (a0)
- EndProc
-
- End